// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name:   CMPP30DeliverRepMessage.java

package com.haoxi.gateway.test.message;

import com.haoxi.gateway.test.CMPPConstant;
import com.haoxi.gateway.test.util.TypeConvert;

public class CMPP30DeliverRepMessage extends CMPPMessage {

    private long msgID;

    private int result;

    public CMPP30DeliverRepMessage(byte msg_Id[], int result)
            throws IllegalArgumentException {
        if (msg_Id.length > 8) {
            throw new IllegalArgumentException(String.valueOf(String
                    .valueOf((new StringBuffer(String.valueOf(String
                            .valueOf(CMPPConstant.DELIVER_REPINPUT_ERROR))))
                            .append(":msg_Id").append(
                                    CMPPConstant.STRING_LENGTH_GREAT).append(
                                    "8"))));
        }
        if (result < 0 || result > 0x7fffffff) {
            throw new IllegalArgumentException(String.valueOf(String
                    .valueOf((new StringBuffer(String.valueOf(String
                            .valueOf(CMPPConstant.DELIVER_REPINPUT_ERROR))))
                            .append(":result").append(
                                    CMPPConstant.INT_SCOPE_ERROR))));
        } else {
            int len = 24;
            buf = new byte[len];
            TypeConvert.int2byte(len, buf, 0);
            TypeConvert.int2byte(0x80000005, buf, 4);
            System.arraycopy(msg_Id, 0, buf, 12, msg_Id.length);
            TypeConvert.int2byte(result, buf, 20);
        }
    }

    public CMPP30DeliverRepMessage(byte buf[]) throws IllegalArgumentException {
        super.buf = new byte[buf.length];
        System.arraycopy(buf, 0, super.buf, 0, buf.length);
    }

    public long getMsgID() {
        byte[] tmp = new byte[8];
        System.arraycopy(this.buf, 12, tmp, 0, 8);
        this.msgID = TypeConvert.byte2long(tmp);
        return msgID;
    }

    public String getMsgIDStr() {
        byte[] tmp = new byte[8];
        System.arraycopy(this.buf, 12, tmp, 0, 8);
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < tmp.length; i++) {
            buffer.append(tmp[i]);
        }
        return buffer.toString();
    }

    public int getResult() {
        this.result = TypeConvert.byte2int(buf, 20);
        return result;

    }

    public int getMessage_Length() {
        message_Length = TypeConvert.byte2int(buf, 0);
        return message_Length;
    }

    public int getSequenceId() {
        sequence_Id = TypeConvert.byte2int(buf, 8);
        return sequence_Id;
    }

    public String toString() {
        String tmpStr = "CMPP_Deliver_REP: ";
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr))))
                .append("\r\nMessage_Length=").append(getMessage_Length())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nCommandId=")
                .append(getCommandId())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nSequence_Id=")
                .append(getSequenceId())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nMsgIdStr=")
                .append(getMsgIDStr())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nResult=")
                .append(getResult())));
        tmpStr = String.valueOf(tmpStr);
        return tmpStr;
    }

    public int getCommandId() {
        return 0x80000005;
    }
}
